<template>
<div class="carbutton">
  <i class="icon iconfont icon-jianhao1" v-show="food.count>0" @click="reduce()"></i>
  <span v-show="food.count>0">{{food.count}}</span>
  <i class="icon iconfont icon-iconfontxinzeng" @click="add($event)"></i>
</div>
</template>
<script>
import Vue from "vue"
export default {
  props: {
    food: {
      type: Object
    }
  },
  methods: {
    add(event) {
      if (!this.food.count) {
        Vue.set(this.food, 'count', 1)
        // this.food.count = 1;
      } else {
        this.food.count++;
      }
      console.log(event.target);
      this.$emit('ball-click', event.target);
    },
    reduce() {
      this.food.count--;
    }

  },
  mounted() {}
}
</script>
<style lang="less">
@import '../../static/less/var.less';

.carbutton {
    font-size: @base*30rem;
    color: @mc;
    span {
        display: inline-block;
        width: @base*20rem;
        text-align: center;
        color: @fc1;
        line-height: @base*30rem;
    }
}
</style>
